<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>16.9.DOM-事件高级-常用的键盘事件</title>
</head>

<body>
    <script>
        // 常用的键盘事件
        // 1.keyup：某个按键被松开时触发
        // document.onkeyup = function () {
        //     console.log('弹起了');
        // }
        document.addEventListener('keyup', function () {
            console.log('keyup');
        })
        // 2.keydown：某个按键被按下时触发
        document.addEventListener('keydown', function () {
            console.log('keydown');
        })
        // 3.keypress：某个按键被按下时触发（但不识别功能键，如ctrl、shift、箭头等）
        document.addEventListener('keypress', function () {
            console.log('keypress');
        })
        // 4.三个事件的执行顺序 keydown->keypress->keyup
    </script>
</body>

</html>